﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PasswordGenerator
{
    internal class PasswordProfile
    {
        List<PasswordRequirement> requirements;
        string password;
        bool requirementFullfilled;

        public PasswordProfile(List<PasswordRequirement> reqs)
        {
            MINIMUM_LENGTH = 14;
            MAXIMUM_LENGTH = MINIMUM_LENGTH + 4;

            requirements = new List<PasswordRequirement>(reqs);

            // remove all PasswordLength requirement from the list
            // set the password length
            for (int i = requirements.Count - 1; i >= 0; i--)
            {
                if (requirements[i] is PasswordLength)
                {
                    MINIMUM_LENGTH = (requirements[i] as PasswordLength).Length;
                    MAXIMUM_LENGTH = MINIMUM_LENGTH + 4;

                    requirements.RemoveAt(i);
                }
            }

            password = string.Empty;
            requirementFullfilled = false;
        }

        #region Properties
        public string Password { get { return password; } set { password = value; } }
        public bool RequirementFullfilled { get { return requirementFullfilled; } set { requirementFullfilled = value; } }
        public List<PasswordRequirement> Requirements { get { return requirements; } }
        public int MAXIMUM_LENGTH { get; private set; }
        public int MINIMUM_LENGTH { get; private set; }
        #endregion
    }
}
